/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.opgea.token.domain.entities;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import com.opgea.token.domain.qualifiers.UserTypeQualifier;

/**
 * 
 * @author Ramesh
 */
@Entity
@Table(name = "login")
@XmlRootElement
@NamedQueries({
	@NamedQuery(name = "Login.findAll", query = "SELECT l FROM Login l"),
	@NamedQuery(name = "Login.findByLoginId", query = "SELECT l FROM Login l WHERE l.loginId = :loginId"),
	@NamedQuery(name = "Login.findByPassword", query = "SELECT l FROM Login l WHERE l.password = :password") })
public class Login implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;
    private String loginId;
    private String password;
    private Boolean isActive;
    @Enumerated(EnumType.STRING)
    private UserTypeQualifier userType;
    @OneToOne
    private Employee employee;

    public Login() {
    }

    public String getLoginId() {
	return loginId;
    }

    public void setLoginId(String loginId) {
	this.loginId = loginId;
    }

    public String getPassword() {
	return password;
    }

    public void setPassword(String password) {
	this.password = password;
    }

    public Employee getEmployee() {
	return employee;
    }

    public void setEmployee(Employee employee) {
	this.employee = employee;
    }

    public long getId() {
	return id;
    }

    public void setId(long id) {
	this.id = id;
    }

    public Boolean getIsActive() {
	return isActive;
    }

    public void setIsActive(Boolean isActive) {
	this.isActive = isActive;
    }

    public UserTypeQualifier getUserType() {
	return userType;
    }

    public void setUserType(UserTypeQualifier userType) {
	this.userType = userType;
    }

    @Override
    public boolean equals(Object obj) {
	if (obj == null) {
	    return false;
	}
	if (getClass() != obj.getClass()) {
	    return false;
	}
	final Login other = (Login) obj;
	if ((this.loginId == null) ? (other.loginId != null) : !this.loginId
		.equals(other.loginId)) {
	    return false;
	}
	return true;
    }

    @Override
    public int hashCode() {
	int hash = 7;
	hash = 29 * hash + (this.loginId != null ? this.loginId.hashCode() : 0);
	return hash;
    }

    @Override
    public String toString() {
	return "Login [id=" + id + ", loginId=" + loginId + ", password="
		+ password + ", isActive=" + isActive + ", userType="
		+ userType + ", employee=" + employee + "]";
    }

}
